<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>05.form_fields | KnockOut</title>
  <script src="../assets/knockout-3.5.1.js"></script>
</head>
<body>

  <form data-bind="submit: doSomething">
    <input type="text" name="username" placeholder="请输入用户名">
    ... form contents go here ...
    <button type="submit">Submit</button>
  </form>
 
  <script type="text/javascript">
    var vm = {
      doSomething : function(formElement) {
        // formElement 表单元素，用于其他操作，例如表单验证等
        // if ($(formElement).valid()) { /* do something */ }.
        console.log(formElement)
      }
    };

    ko.applyBindings(vm);
  </script>

</body>
</html>